<?php

require('BDecode.php');
require('BEncode.php');
 
$filename = "torrents/DISC 4 (4).torrent";
$tfile = BDecode(file_get_contents($filename));
$infohash = sha1(BEncode($tfile['info']));
$tr = urlencode($tfile['announce']);
$filename_encoded = rawurlencode($tfile['info']['name']);

$url = "magnet:?xt=urn:btih:$infohash&tr=$tr&dn=$filename_encoded";

?>
<body>
<br />
<a href="<?php echo $url?>">Magnet link php</a>
<script type="text/javascript">
var torrent_file = "<?php echo $filename; ?>";
</script>
<script type="text/javascript" src="js/PHPJS.js"></script>
<script type="text/javascript" src="js/Torrent.js"></script>
<script type="text/javascript" src="js/test.js"></script>
</body>
